from applications.extensions import db


class AppUser(db.Model):
    """Basic user model"""

    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(255), unique=True, nullable=False, comment="用户名")
    phone = db.Column(db.String(255), unique=True, comment="电话")
    email = db.Column(db.String(80), unique=True, comment="邮箱")
    password = db.Column(db.String(255), nullable=False, comment="密码")
    active = db.Column(db.Boolean, default=True, comment="激活状态")

    def to_dict(self):
        return {
            "id": self.id,
            "username": self.username,
            "phone": self.phone,
            "email": self.email,
            "active": self.active,
        }
